package com.trace.pplos.parse.dao.dataobject;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Date;

public class LdrkInfo {
    private static final Logger logger = LoggerFactory.getLogger(LdrkInfo.class);

    private Integer id;

    private String pName;

    private String sex;

    private String idcard;

    private String addres;

    private String censusRegister;

    private String nation;

    private String education;

    private String works;

    private String marriage;

    private String phone;

    private String memo;

    private String photoPath;

    private String jzzPath;

    private String sfzPath;

    private String lng;

    private String lat;

    private String addr;

    private String cjdw;

    private String filepath;

    private String locMapSnapPath;

    private Date gmtCreate;

    private String gmtCreateUser;

    private Date gmtModified;

    private String gmtModifiedUser;

    private Integer status;

    public LdrkInfo(Integer id, String pName, String sex, String idcard, String addres, String censusRegister, String nation, String education, String works, String marriage, String phone, String memo, String photoPath, String jzzPath, String sfzPath, String lng, String lat, String addr, String cjdw, String filepath, String locMapSnapPath, Date gmtCreate, String gmtCreateUser, Date gmtModified, String gmtModifiedUser, Integer status) {
        this.id = id;
        this.pName = pName;
        this.sex = sex;
        this.idcard = idcard;
        this.addres = addres;
        this.censusRegister = censusRegister;
        this.nation = nation;
        this.education = education;
        this.works = works;
        this.marriage = marriage;
        this.phone = phone;
        this.memo = memo;
        this.photoPath = photoPath;
        this.jzzPath = jzzPath;
        this.sfzPath = sfzPath;
        this.lng = lng;
        this.lat = lat;
        this.addr = addr;
        this.cjdw = cjdw;
        this.filepath = filepath;
        this.locMapSnapPath = locMapSnapPath;
        this.gmtCreate = gmtCreate;
        this.gmtCreateUser = gmtCreateUser;
        this.gmtModified = gmtModified;
        this.gmtModifiedUser = gmtModifiedUser;
        this.status = status;
    }

    public LdrkInfo() {
        super();
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getpName() {
        return pName;
    }

    public void setpName(String pName) {
        this.pName = pName == null ? null : pName.trim();
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex == null ? null : sex.trim();
    }

    public String getIdcard() {
        return idcard;
    }

    public void setIdcard(String idcard) {
        this.idcard = idcard == null ? null : idcard.trim();
    }

    public String getAddres() {
        return addres;
    }

    public void setAddres(String addres) {
        this.addres = addres == null ? null : addres.trim();
    }

    public String getCensusRegister() {
        return censusRegister;
    }

    public void setCensusRegister(String censusRegister) {
        this.censusRegister = censusRegister == null ? null : censusRegister.trim();
    }

    public String getNation() {
        return nation;
    }

    public void setNation(String nation) {
        this.nation = nation == null ? null : nation.trim();
    }

    public String getEducation() {
        return education;
    }

    public void setEducation(String education) {
        this.education = education == null ? null : education.trim();
    }

    public String getWorks() {
        return works;
    }

    public void setWorks(String works) {
        this.works = works == null ? null : works.trim();
    }

    public String getMarriage() {
        return marriage;
    }

    public void setMarriage(String marriage) {
        this.marriage = marriage == null ? null : marriage.trim();
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone == null ? null : phone.trim();
    }

    public String getMemo() {
        return memo;
    }

    public void setMemo(String memo) {
        this.memo = memo == null ? null : memo.trim();
    }

    public String getPhotoPath() {
        return photoPath;
    }

    public void setPhotoPath(String photoPath) {
        this.photoPath = photoPath == null ? null : photoPath.trim();
    }

    public String getJzzPath() {
        return jzzPath;
    }

    public void setJzzPath(String jzzPath) {
        this.jzzPath = jzzPath == null ? null : jzzPath.trim();
    }

    public String getSfzPath() {
        return sfzPath;
    }

    public void setSfzPath(String sfzPath) {
        this.sfzPath = sfzPath == null ? null : sfzPath.trim();
    }

    public String getLng() {
        return lng;
    }

    public void setLng(String lng) {
        this.lng = lng == null ? null : lng.trim();
    }

    public String getLat() {
        return lat;
    }

    public void setLat(String lat) {
        this.lat = lat == null ? null : lat.trim();
    }

    public String getAddr() {
        return addr;
    }

    public void setAddr(String addr) {
        this.addr = addr == null ? null : addr.trim();
    }

    public String getCjdw() {
        return cjdw;
    }

    public void setCjdw(String cjdw) {
        this.cjdw = cjdw == null ? null : cjdw.trim();
    }

    public String getFilepath() {
        return filepath;
    }

    public void setFilepath(String filepath) {
        this.filepath = filepath == null ? null : filepath.trim();
    }

    public String getLocMapSnapPath() {
        return locMapSnapPath;
    }

    public void setLocMapSnapPath(String locMapSnapPath) {
        this.locMapSnapPath = locMapSnapPath == null ? null : locMapSnapPath.trim();
    }

    public Date getGmtCreate() {
        return gmtCreate;
    }

    public void setGmtCreate(Date gmtCreate) {
        this.gmtCreate = gmtCreate;
    }

    public String getGmtCreateUser() {
        return gmtCreateUser;
    }

    public void setGmtCreateUser(String gmtCreateUser) {
        this.gmtCreateUser = gmtCreateUser == null ? null : gmtCreateUser.trim();
    }

    public Date getGmtModified() {
        return gmtModified;
    }

    public void setGmtModified(Date gmtModified) {
        this.gmtModified = gmtModified;
    }

    public String getGmtModifiedUser() {
        return gmtModifiedUser;
    }

    public void setGmtModifiedUser(String gmtModifiedUser) {
        this.gmtModifiedUser = gmtModifiedUser == null ? null : gmtModifiedUser.trim();
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public static LdrkInfo toBean(String object){
        try{
            LdrkInfo info = new LdrkInfo();
            JSONObject record = JSON.parseObject(object);
            info.setAddr(record.getString("address"));
            info.setAddres(record.getString("xjdz"));
            info.setpName(record.getString("ryxm"));
            info.setIdcard(record.getString("sfzh"));
            info.setSex(record.getString("ryxb"));
            info.setMarriage(record.getString("hyzk"));
            info.setCensusRegister(record.getString("hjdz"));
            info.setWorks(record.getString("ryzy"));
            info.setMemo(record.getString("ryms"));
            info.setLat(record.getString("latitude"));
            info.setLng(record.getString("longitude"));

            info.setGmtCreate(record.getDate("createdAt"));
            info.setGmtCreateUser(record.getString("createdBy"));
            //info.setGmtModified(record.getDate("modifiedAt"));
            info.setGmtModified(new Date());
            info.setGmtModifiedUser(record.getString("modifiedBy"));

            //人员照片图片
            String filePaths = "";
            JSONArray list = record.getJSONArray("xxzlPictureList");
            for (int i = 0; i < list.size(); i++) {
                JSONObject dataObj = list.getJSONObject(i);
                filePaths += dataObj.getString("path") +",";
            }
            info.setPhotoPath(filePaths);

            //方位图
            filePaths = "";
            list = record.getJSONArray("xcfwPictureList");
            for (int i = 0; i < list.size(); i++) {
                JSONObject dataObj = list.getJSONObject(i);
                filePaths += dataObj.getString("path") +",";
            }
            info.setLocMapSnapPath(filePaths);
            return info;
        }catch (Exception e){
            logger.error(e.getMessage(), e);
        }
        return null;
    }
}